package com.web.demo.controller;

import com.web.demo.model.MessageDto;
import com.web.demo.service.ALiService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;

@RestController
@AllArgsConstructor
public class ChatController {

    private ALiService aLiService;

    @PostMapping(value = "/chat")
    public ResponseBodyEmitter chat(@RequestBody @Validated MessageDto messageDto) {
        ResponseBodyEmitter emitter = new ResponseBodyEmitter();
        aLiService.chat(messageDto, emitter);
        return emitter;
    }
}
